package com.ruoyi.school.course.controller;

import com.ruoyi.school.course.domain.Course;
import com.ruoyi.school.course.service.ICourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/school/course")
public class StudentCourseController
{
    private String prefix = "school/course";

    @Autowired
    private ICourseService courseService;

    @RequestMapping("/student_course")
    public String courseList(Model m)
    {
        // 查询课程列表
        List<Course> list = courseService.selectCourseList(null);
        m.addAttribute("courses",list);

        return prefix+"/student_course_list";
    }

    @RequestMapping("/student_course_detail")
    public String courseDetail(long courseId,Model m)
    {
        // 课程详情
        Course course = courseService.selectCourseById(courseId);
        m.addAttribute("course",course);

        return prefix+"/student_course_detail";
    }
}
